<?
session_start();
if (!isset($_SESSION[login])) {
     header("Location: HomeIndex.php");
     exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home Admin</title>
<meta charset="utf-8">
<meta name="description" content="Place your description here">
<meta name="keywords" content="put, your, keyword, here">
<meta name="author" content="Templates.com - website templates provider">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<!--[if lt IE 7]>
     <link rel="stylesheet" href="css/ie/ie6.css" type="text/css" media="screen">
     <script type="text/javascript" src="js/ie_png.js"></script>
     <script type="text/javascript">
        ie_png.fix('.png, footer, header nav ul li a, .nav-bg, .list li img');
     </script>
<![endif]-->
<!--[if lt IE 9]>
  	<script type="text/javascript" src="js/html5.js"></script>
  <![endif]-->
<SCRIPT LANGUAGE="JavaScript">

function submitform(){
	searchpro.submit();
}
</script>
</head>
<body id="page1">
<div class="wrap">
<!-- header -->
<header>
  <div class="container">
    <h1><a href="homeAdmin.php">Student Portfolio Management System</a></h1>
    <nav>
      <ul>
        <li><a href="homeAdmin.php" class="m1">หน้าแรก</a></li>
        <li><a href="searchAdmin.php" class="m1">ค้นหา</a></li>
        <li><a href="uploadAdmin.php" class="m1">อัพโหลด</a></li>
        <li class="current"><a href="manageAdmin.php" class="m3">จัดการข้อมูลเบื้องต้น</a></li>
        <li class="last"><a href="reportAdmin.php" class="m3">ออกรายงาน</a></li>
      </ul>
    </nav>
    <form action="" id="search-form">
      <fieldset>
        <div class="rowElem">
          <input type="text">
          <a href="#" onClick="document.getElementById('search-form').submit()">ค้นหา</a></div>
      </fieldset>
    </form>
  </div>
</header>
<div class="container">
<!-- aside -->
<aside>
  <div class="wrap"> 
    <!-- header -->
    <div class="container"> 
      <!-- aside -->
      <aside>
        <h2 align ="left">ยินดีต้อนรับ</h2>
		 <p><? echo $_SESSION["ses_name"]; ?></p>
       <input name="editSelf" type="button" value="แก้ไขข้อมูลส่วนตัว" onClick="window.location='editselfAdmin.php'"><br><br>
      <input name="logOut" type="button" value="ออกจากระบบ" onClick="window.location='logout.php'">
      </aside>
      <!-- content -->
      <section id="content">
        <div class="inside"> </div>
      </section>
    </div>
  </div>
</aside>
<!-- content -->
<section id="content">
<div class="inside">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td><p class="style30">ระบบจัดการเพิ่ม-ลบ-แก้ไขบัญชีผู้ใช้</p>
    <hr />
    <p></p></td></tr>
		</table>
		<table width="500" height="20" border="0" cellpadding="0" cellspacing="0">
		<tr>
      <td><form name="searchpro" method="post" action="adAdmin.php">
          <div align="right">
            <select name="selectpro">
              <option selected="selected">ชื่อผู้ใช้</option>
			  <option>รหัสนักศึกษา</option>
              <option>ชื่อสาขา</option>
            </select>
          </div>
      </td>
      <td valign="middle">&nbsp;&nbsp;ค้นหา&nbsp;&nbsp;</td>
      <td>
          <input type="text" size="50" name="text" />

      </td>
		<td> 
              <input type="button" onClick="submitform()" value="ค้นหา" />
        </form>
     </td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
	</table>
<table width="650" height="30" border="1" cellpadding="0" cellspacing="0">
  <tr bordercolor="#999999">
    <td width="104" height="40" valign="middle" bgcolor="#C2CFDF"><div align="center" class="style29"><b>ชื่อ</b></div></td>
    <td width="113" valign="middle" bgcolor="#C2CFDF"><div align="center" class="style29"><b>นามสกุล</b></div></td>
    <td width="60" valign="middle" bgcolor="#C2CFDF"><div align="center" class="style29"><b>สาขา</b></div></td>
    <td width="192" valign="middle" bgcolor="#C2CFDF"><div align="center" class="style29"><b>E-mail</b></div></td>
    <td width="123" valign="middle" bgcolor="#C2CFDF"><div align="center" class="style29"><b>แก้ไขบัญชีสมาชิก</b></div></td>
    <td width="108" valign="middle" bgcolor="#C2CFDF"><div align="center" class="style29"><b>ลบบัญชีสมาชิก</b></div></td>
  </tr>
<? require("connectDB.php");    //include "connectdb.inc";
if ($selectpro == "ชื่อผู้ใช้")
$tmp="select * from user_account where name like '$text%' order by user_id;";
else if ($selectpro == "รหัสนักศึกษา")
$tmp="select * from user_account where student_id like '$text%' order by user_id;";
elseif ($selectpro == "ชื่อสาขา")
$tmp="select * from User_account where major like '$text%' order by user_id;";
else
$tmp="select * from User_account order by user_id;";

//echo($tmp);
$sql = mysql_query($tmp);
while($result = mysql_fetch_array($sql))    { ?>
<TR>
<TD height="30" valign="middle"><? echo $result["name"]; ?></TD>
<td valign="middle"><? echo $result["lastname"]; ?></td>
<td valign="middle"><? echo $result["major"]; ?></td>
<td valign="middle"><? echo $result["email"]; ?></td>
<TD align="center" valign="middle"> <a href="manageMember.php?id=<? echo $result["user_id"]; ?>" >แก้ไข</TD>
<TD align="center" valign="middle"> <a href="deleteMember.php?id=<? echo $result["user_id"]; ?>" >ลบ</TD>
</tr>
<? }
mysql_free_result($sql);
mysql_close($con); ?>
</table>
<input name="adAcc" type="button" onclick="window.location='addMember.php'" value="เพิ่มบัญชีผู้ใช้" />
</div>
</section>
</body>
</html>
